<{capture name="header"}>
<{css src="template.css" app="desktop" }>
<style> 
div.workground{padding:0;}
</style>
<{/capture}>
<{capture name="headbar"}>
<div id="wg_toolbar" class="toolbar clearfix content-toolbar"> 
	<div class="flt"><strong><{t}>单独页编辑<{/t}></strong>( <{$detail.title}> )</div>
	<div class="span-auto">&nbsp;</div>
	<div class="flt">
			
			<a class="tbbtn layout btn-chg-layout" href="javascript:void(0)">
				<span>	<{t}>选择页面布局<{/t}><span>
			</a>
			<a class="tbbtn add btn-addwgt" href="javascript:void(0)">
				<span>	<{t}>添加版块<{/t}><span>
			</a>
    </div>
	<div class="btn-bar frt">
		<a class="tbbtn save" href="javascript:void(0)" onclick="if(confirm('<{t}>确定保存您对当前页面的修改吗?<{/t}>'))_saveWidgets()">
			<span>	<{t}>保存<{/t}></span>
		</a>
		<a class="tbbtn view" href="<{$site_url}>" target="_blank">
			<span>	<{t}>浏览<{/t}></span>
		</a>
		<a class="tbbtn exit" href="javascript:void(0)" onclick="if(confirm('<{t}>确定退出?<{/t}>'))window.close()">
			<span>	<{t}>退出<{/t}></span>
		</a>
	</div>

</div>
<{/capture}>

<iframe src="index.php?app=content&ctl=admin_article_single&act=preview&article_id=<{$detail.indexs.article_id}>" width='100%' height='100%' frameborder=0 id="themeFrame" name="themeFrame"></iframe>


<input type="hidden" name="ident" value="<{$detail.indexs.article_id}>">
<script>    
window.addEvent('domready',function(){
Ex_Loader('modedialog',function(){});

		window.addEvent('resize',function(){
	

			$('themeFrame').set('height',window.getSize().y-$('wg_toolbar').getSize().y-$('wg_toolbar').getPatch().y);
	
	
		}).fireEvent('resize');	    
	});
		 var shopWidgetsOBJ=$('themeFrame').contentWindow.shopWidgets;
		 var addWidget=$E('.btn-addwgt','content-toolbar');
		 var cl=$E('.btn-chg-layout','content-toolbar');
		 var saveBtn=$E('.btn-savewgt','content-toolbar');
		 if(cl)
		 cl.addEvent('click',function(){
			 if(confirm('<{t}>选择布局前需要先保存当前页面编辑状态,保存吗?<{/t}>')){
					_saveWidgets();
			 }else{
					return;
			 }
			 this.store('dialog',new Dialog('index.php?app=content&ctl=admin_article_single&act=layout&article_id=<{$detail.indexs.article_id}>',{title:'<{t}>设置布局<{/t}>',modal:true,width:500,height:350}));
		 });
		 
		 addWidget.addEvent('click',function(){
			 _showWidgetsDialog('index.php?app=site&ctl=admin_theme_widget&act=add_widgets_page&theme=<{$theme}>');
		 });
		
   function _addWeigets(args){

      var themeFrame=$('themeFrame').contentWindow;
      var shopWidgetsOBJ=themeFrame.shopWidgets;

    _widgetsDialog?_widgetsDialog.close():'';

    _widgetsDialog=null;

    shopWidgetsOBJ.ghostDrop(args[0],args[1]);

    themeFrame.focus();

   }


   function _showWidgetsDialog(url){

    _widgetsDialog=new Dialog(url,{width:770,height:500,title:'<{t}>增加页面版块<{/t}>',modal:true,resizeable:false,onShow:function(e){

     this.dialog_body.id='dialogContent';

  }});

   }


   function _saveWidgets(){

		$("themeFrame").contentWindow.shopWidgets.saveAll();
		new Request({url:'index.php?app=content&ctl=admin_article_detail&act=updatetime&article_id=<{$detail.indexs.article_id}>'}).send()
	return false;
   }
	
	var SHOPADMINDIR = '<{$shopadmin}>';

</script>
